import 'package:flutter/material.dart';
import 'package:flutter_enjoy/pagess/home/components/detail.dart';

class Mode2 extends StatefulWidget {
  final List announcementList;
  const Mode2({super.key, required this.announcementList});

  @override
  // ignore: library_private_types_in_public_api
  _Mode2State createState() => _Mode2State();
}

class _Mode2State extends State<Mode2> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListView.builder(
        itemCount: widget.announcementList.length,
        shrinkWrap: true,
        itemBuilder: (context, index) {
          return Column(
            children: [
              GestureDetector(
                onTap: () {
                  Navigator.pushNamed(context, '/notic_detail',
                      arguments: widget.announcementList[index]['id']);
                },
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(widget.announcementList[index]['title'],
                        style: TextStyle(
                            fontSize: 16, fontWeight: FontWeight.bold)),
                    SizedBox(height: 8),
                    Text(
                      widget.announcementList[index]['content'],
                      style: TextStyle(fontSize: 14, color: Colors.black87),
                    ),
                    SizedBox(height: 12),
                    Text(widget.announcementList[index]['createdAt'],
                        style: TextStyle(fontSize: 12, color: Colors.grey)),
                  ],
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}
